<template>
  <view class="login_container">
    <view class="img_box">
      <image src="/static/xpsh.png" class="xpsh_img"></image>
    </view>
    <!-- <van-icon name="manager-o" /> -->
    <view class="login_box">
      <van-field
        :value="params.user"
        clearable
        placeholder="请输入账号"
        :border="false"
        style="margin-bottom: 30upx !important"
      >
        <!-- <view slot="left-icon" class="van-icon">
          <van-icon name="manager-o" />
        </view> -->
      </van-field>
      <van-field
        :value="params.password"
        type="password"
        clearable
        placeholder="请输入密码"
        :border="false"
      >
        <!-- <view slot="left-icon" class="van-icon">
          <van-icon name="manager-o"></van-icon>
        </view> -->
      </van-field>

      <!-- <van-button color=" #6D55ED" custom-class="login_btn" block round @tap="login">登录</van-button> -->
      <view class="login_btn" @tap="login">登录</view>
      <van-toast id="van-toast" />
    </view>
  </view>
</template>

<script>
import { login1 } from "../../utils/imapi";
import { setData } from "../../utils/storage";
export default {
  props: {},
  components: {},
  data() {
    return {
      // params: {
      //   user: "4",
      //   password: "xingkong",
      //   from_c: "1",
      //   login_type: "1",
      // },
      params: {
        user: "admin",
        password: "123456",
        from_c: "1",
        login_type: "1",
      },
    };
  },
  watch: {},
  onLoad() {},
  onReady() {},
  onShow() {},
  methods: {
    async login() {
      console.log(1111);
      // 验证账号密码

      // 登录成功 把token放在 storage 和 vuex
      try {
        const data = await login1({
          user: "admin",
          password: "123456",
          from_c: "2",
          login_type: "1",
        });
        console.log(data);
        if (data.code == 0) {
          const token = data.data
          setData("token",token);
         this.$toast.loading('登录中...')
          setTimeout(() => {
               // 跳转到首页
          uni.reLaunch({
            url: "/pages/index/index",
          });
          }, 1000);
        }
      } catch (error) {
        console.log(error);
      }
    },
  },
  onReachBottom() {},
  onHide() {},
};
</script>

<style  lang="scss" scoped>
.login_container {
  width: 100%;
  padding: 0 60upx;
}
.img_box {
  width: 750upx;
  .xpsh_img {
    width: 424upx;
    height: 354upx;
    margin-top: 256upx;
    margin-left: 102upx;
  }
}
.login_box {
  margin-top: 188upx;
}
/deep/ .custom-class {
  border-bottom: 2upx solid #e1e1e3 !important;
  margin-bottom: 10px;
}
.van-icon {
  margin: 10upx 36upx 0 36upx;
}
/deep/ .login_btn {
  width: 630upx;
  height: 88upx;
  background: #6d55ed;
  border-radius: 46upx;
  text-align: center;
  line-height: 88upx;
  color: #fff;
  margin-top: 58upx;
}
</style>
